package zjh.msg.servelt;

import zjh.msg.dao.MsgDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/insertMsg")
public class InsertServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String nickname = req.getParameter("Books_Name");
        String text = req.getParameter("Books_Info");
        String qq = req.getParameter("Books_Qq");
        String email = req.getParameter("Books_Mail");
        String replyId = req.getParameter("Books_ReplyId");

        MsgDao msgDao = new MsgDao();
        msgDao.insertMsg(nickname, text, qq, email, replyId);
//        重定向
        resp.sendRedirect("/listMsg");
    }
}
